package com.moxiao.yfjh.module.maker.dal.mysql.matchmakerRecord;

import com.moxiao.yfjh.module.maker.controller.admin.matchmakerRecord.vo.MatchmakerRecordExportReqVO;
import com.moxiao.yfjh.module.maker.controller.admin.matchmakerRecord.vo.MatchmakerRecordPageReqVO;
import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.maker.dal.dataobject.matchmakerRecord.MatchmakerRecordDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.maker.controller.admin.matchmakerRecord.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲红娘记录 Mapper
 *
 * @author mx
 */
@Mapper
public interface MatchmakerRecordMapper extends BaseMapperX<MatchmakerRecordDO> {

    default PageResult<MatchmakerRecordDO> selectPage(MatchmakerRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MatchmakerRecordDO>()
                .eqIfPresent(MatchmakerRecordDO::getMatchmakerId, reqVO.getMatchmakerId())
                .likeIfPresent(MatchmakerRecordDO::getMatchmakerName, reqVO.getMatchmakerName())
                .eqIfPresent(MatchmakerRecordDO::getMemberId, reqVO.getMemberId())
                .likeIfPresent(MatchmakerRecordDO::getMemberName, reqVO.getMemberName())
                .eqIfPresent(MatchmakerRecordDO::getStringingNum, reqVO.getStringingNum())
                .eqIfPresent(MatchmakerRecordDO::getServeTimeBegin, reqVO.getServeTimeBegin())
                .eqIfPresent(MatchmakerRecordDO::getServeTimeEnd, reqVO.getServeTimeEnd())
                .betweenIfPresent(MatchmakerRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MatchmakerRecordDO::getId));
    }

    default List<MatchmakerRecordDO> selectList(MatchmakerRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MatchmakerRecordDO>()
                .eqIfPresent(MatchmakerRecordDO::getMatchmakerId, reqVO.getMatchmakerId())
                .likeIfPresent(MatchmakerRecordDO::getMatchmakerName, reqVO.getMatchmakerName())
                .eqIfPresent(MatchmakerRecordDO::getMemberId, reqVO.getMemberId())
                .likeIfPresent(MatchmakerRecordDO::getMemberName, reqVO.getMemberName())
                .eqIfPresent(MatchmakerRecordDO::getStringingNum, reqVO.getStringingNum())
                .eqIfPresent(MatchmakerRecordDO::getServeTimeBegin, reqVO.getServeTimeBegin())
                .eqIfPresent(MatchmakerRecordDO::getServeTimeEnd, reqVO.getServeTimeEnd())
                .betweenIfPresent(MatchmakerRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MatchmakerRecordDO::getId));
    }


    @Select("select id from blind_matchmaker_record WHERE member_id = #{memberId} AND (serve_time_end = '' OR serve_time_end IS null)")
    public Long selectMatchmakerRecordByMemberId(@Param("memberId") Long memberId);


}
